package com.pengtu.gsj.dao.afgc;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.pengtu.gsj.dao.hibernate.HibernateDao;
import com.pengtu.gsj.entity.afgc.LifeCherish;

@Repository
public class LifeCherishDao extends HibernateDao<LifeCherish, String>{
	
	public List<LifeCherish> getLifeCherishsYears(){
		String hql = "select new com.pengtu.gsj.entity.afgc.LifeCherish(t.year) from LifeCherish t  where t.delFlag = '0' group by t.year ";
		return find(hql);
	}
	
	/**
	 * 
	 * getLifeCherishsByAll:
	 * 适用:获取某年度各辖区局 各种技术等级  各种处置状态下的工程数量
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	public List<LifeCherish> getLifeCherishsByAll(String year) {
		String hql = "select new com.pengtu.gsj.entity.afgc.LifeCherish(t.county, t.technicalLevel,t.delStatus,count(t.county)) from LifeCherish t WHERE t.year=? and t.delFlag='0' GROUP BY t.county,t.technicalLevel, t.delStatus ORDER BY t.county,t.technicalLevel,t.delStatus";
		return find(hql, year);
	}
	
	/**
	 * 
	 * getlifCherishsByCounty:
	 * 适用:获取某年度各辖区局下面需要处置的工程总数量 部分技术等级和处置状态
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	public List<LifeCherish> getlifCherishsByCounty(String year) {
		String hql = "select new com.pengtu.gsj.entity.afgc.LifeCherish(t.county,count(t.county)) from LifeCherish t WHERE t.year=? and t.delFlag='0' GROUP BY t.county ORDER BY t.county";
		return find(hql, year);
	}
	
	/**
	 * 
	 * getLifeCherishsByTec:
	 * 适用:获得某年度各辖区局下面各技术等级的工程数量
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	public List<LifeCherish> getLifeCherishsByTec(String year) {
		String hql = "select new com.pengtu.gsj.entity.afgc.LifeCherish(t.county,t.technicalLevel,count(t.county)) from LifeCherish t WHERE t.year=? and t.delFlag='0'  GROUP BY t.county,t.technicalLevel ORDER BY t.county";
		return find(hql, year);
	}
	
	/**
	 * 
	 * getLifeCherishsByDelStatus:
	 * 适用:获得某年度各辖区局下面各处置状态的工程数量
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	public List<LifeCherish> getLifeCherishsByDelStatus(String year) {
		String hql = "select new com.pengtu.gsj.entity.afgc.LifeCherish(t.county,count(t.county),t.delStatus) from LifeCherish t WHERE t.year=? and t.delFlag='0' GROUP BY t.county,t.delStatus ORDER BY t.county,t.delStatus";
		return find(hql, year);
	}
}
